Saves an array of AnnContainer to a stream.
public void Save(Stream stream,AnnContainer[] containers,AnnCodecsFormat format)
Public Overloads Sub Save( _ByVal stream As Stream, _ByVal containers() As Leadtools.Annotations.AnnContainer, _ByVal format As Leadtools.Annotations.AnnCodecsFormat _)
public:void Save(Stream^ stream,Leadtools.Annotations.array<AnnContainer^>^ containers,Leadtools.Annotations.AnnCodecsFormat format)
stream
The stream to which to save the array of AnnContainer.
containers
An array of AnnContainer containing the objects to be saved.
format
An AnnCodecsFormat value that specifies the annotation format to use when saving.
This method saves the entire array of AnnContainer to a stream that will contain multipage pages, with each page corresponding to one of the AnnContainer. If stream contains any data, it will be overwritten. If containers contain many AnnContainer, then this method will create the multipage annotation stream much faster than repeated calls to Save(stream,anncontainer,anncodecsformat,int32,anncodecssavepagemode)
This method only supports the AnnCodecsFormat.Xml format. All other AnnCodecsFormat are not supported.
For more information, refer to Annotation Files (Deprecated).
using Leadtools;using Leadtools.Annotations;using Leadtools.Codecs;using Leadtools.WinForms;public void AnnCodecs_SaveStream2(){// create three annotation containers// The first container contains a rectangle objectAnnContainer container0 = new AnnContainer();AnnRectangleObject rectObj = new AnnRectangleObject();rectObj.Bounds = new AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel);rectObj.Pen = new AnnPen(Color.Blue, new AnnLength(1, AnnUnit.Pixel));rectObj.Brush = null;container0.Objects.Add(rectObj);// The second container contains a line objectAnnContainer container1 = new AnnContainer();AnnLineObject lineObj = new AnnLineObject();lineObj.StartPoint = new AnnPoint(100, 100, AnnUnit.Pixel);lineObj.EndPoint = new AnnPoint(200, 200, AnnUnit.Pixel);lineObj.Pen = new AnnPen(Color.Red, new AnnLength(1, AnnUnit.Pixel));container1.Objects.Add(lineObj);// The third container contains a ellipse objectAnnContainer container2 = new AnnContainer();AnnEllipseObject ellipseObj = new AnnEllipseObject();ellipseObj.Bounds = new AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel);ellipseObj.Pen = new AnnPen(Color.Blue, new AnnLength(1, AnnUnit.Pixel));ellipseObj.Brush = null;container2.Objects.Add(ellipseObj);// create a memory stream to save both annotation containersusing (MemoryStream ms = new MemoryStream()){// create a new AnnCodecs classAnnCodecs codecs = new AnnCodecs();// save both AnnContainers into the streamcodecs.Save(ms, container0, AnnCodecsFormat.Xml, 1, AnnCodecsSavePageMode.Overwrite);ms.Seek(0, SeekOrigin.Begin);codecs.Save(ms, container1, AnnCodecsFormat.Xml, 2, AnnCodecsSavePageMode.Insert);ms.Seek(0, SeekOrigin.Begin);// Now load both containers from the stream, and verify that there are two containersAnnContainer[] containersTwo = codecs.Load(ms);MessageBox.Show(String.Format("After Load: there should be 2 containers. Total number of containers: {0}", containersTwo.Length));// Add another container, and save to the streamAnnContainer[] containersNew = new AnnContainer[containersTwo.Length + 1];Array.Copy(containersTwo, containersNew, containersTwo.Length);containersNew[2] = container2;ms.Seek(0, SeekOrigin.Begin);codecs.Save(ms, containersNew, AnnCodecsFormat.Xml);ms.Seek(0, SeekOrigin.Begin);// Load and verify that there are three containersAnnContainer[] containersThree = codecs.Load(ms);MessageBox.Show(String.Format("After Load: there should be 3 containers. Total number of containers: {0}", containersThree.Length));}}
Imports LeadtoolsImports Leadtools.AnnotationsImports Leadtools.CodecsImports Leadtools.WinFormsPublic Sub AnnCodecs_SaveStream2()' create three annotation containers' The first container contains a rectangle objectDim container0 As New AnnContainer()Dim rectObj As New AnnRectangleObject()rectObj.Bounds = New AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel)rectObj.Pen = New AnnPen(Color.Blue, New AnnLength(1, AnnUnit.Pixel))rectObj.Brush = Nothingcontainer0.Objects.Add(rectObj)' The second container contains a line objectDim container1 As New AnnContainer()Dim lineObj As New AnnLineObject()lineObj.StartPoint = New AnnPoint(100, 100, AnnUnit.Pixel)lineObj.EndPoint = New AnnPoint(200, 200, AnnUnit.Pixel)lineObj.Pen = New AnnPen(Color.Red, New AnnLength(1, AnnUnit.Pixel))container1.Objects.Add(lineObj)' The third container contains a ellipse objectDim container2 As New AnnContainer()Dim ellipseObj As New AnnEllipseObject()ellipseObj.Bounds = New AnnRectangle(100, 100, 100, 100, AnnUnit.Pixel)ellipseObj.Pen = New AnnPen(Color.Blue, New AnnLength(1, AnnUnit.Pixel))ellipseObj.Brush = Nothingcontainer2.Objects.Add(ellipseObj)' create a memory stream to save both annotation containersUsing ms As New MemoryStream()' create a new AnnCodecs classDim codecs As New AnnCodecs()' save both AnnContainers into the streamcodecs.Save(ms, container0, AnnCodecsFormat.Xml, 1, AnnCodecsSavePageMode.Overwrite)ms.Seek(0, SeekOrigin.Begin)codecs.Save(ms, container1, AnnCodecsFormat.Xml, 2, AnnCodecsSavePageMode.Insert)ms.Seek(0, SeekOrigin.Begin)' Now load both containers from the stream, and verify that there are two containersDim containersTwo() As AnnContainer = codecs.Load(ms)MessageBox.Show(String.Format("After Load: there should be 2 containers. Total number of containers: {0}", containersTwo.Length))' Add another container, and save to the streamDim containersNew(containersTwo.Length) As AnnContainerArray.Copy(containersTwo, containersNew, containersTwo.Length)containersNew(2) = container2ms.Seek(0, SeekOrigin.Begin)codecs.Save(ms, containersNew, AnnCodecsFormat.Xml)ms.Seek(0, SeekOrigin.Begin)' Load and verify that there are three containersDim containersThree() As AnnContainer = codecs.Load(ms)MessageBox.Show(String.Format("After Load: there should be 3 containers. Total number of containers: {0}", containersThree.Length))End UsingEnd Sub
Raster .NET | C API | C++ Class Library | JavaScript HTML5
Document .NET | C API | C++ Class Library | JavaScript HTML5
Medical .NET | C API | C++ Class Library | JavaScript HTML5
Medical Web Viewer .NET
